Repository navigation
feat(gax): enter inScope() during CompositeTracer completion callbacks - #15034
jinseopkim0 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates CompositeTracer to wrap its lifecycle and attempt completion methods within the tracer's scope using a try-with-resources block, and adds a null check to ignore null child scopes in inScope(). Corresponding unit tests have been added to verify these scoping behaviors, including nested composite tracers and cross-thread scoping. I have no additional feedback to provide as no review comments were submitted.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request updates CompositeTracer to execute operation and attempt lifecycle methods within the active scope and safely handle null scopes returned by unstubbed mocks. It also adds unit tests to verify scope management and cross-thread scoping. Feedback on these changes suggests catching Throwable instead of RuntimeException when establishing child scopes to prevent potential thread-local scope leaks if an Error occurs during scope creation.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request enhances CompositeTracer by wrapping operation and attempt methods in try-with-resources blocks to manage scopes correctly. It also improves robustness by handling Error alongside RuntimeException during scope creation and closing, ignoring null child scopes, and ensuring scope closure is idempotent. The review feedback suggests optimizing the inScope implementation by replacing AtomicBoolean with a local class to reduce object allocation and memory barrier overhead, which would also make the AtomicBoolean import redundant.
…eTracer.inScope()
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request updates CompositeTracer to handle null scopes returned by child tracers, catch and propagate Errors alongside RuntimeExceptions, and wrap child tracer callbacks in their corresponding scopes using try-with-resources. It also replaces the anonymous Scope implementation with a CompositeScope class to prevent double-closing. Comprehensive unit tests are added to verify these behaviors, including cross-thread scoping scenarios. The reviewer suggested optimizing inScope() to avoid allocations when there are zero or one child tracers.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request updates CompositeTracer to optimize scope handling (including fast paths for empty or single-child lists), catch and handle Error alongside RuntimeException, and wrap operation and attempt methods in try-with-resources blocks to manage scopes properly. Comprehensive unit tests are added to cover these scenarios. The review feedback highlights a potential concurrency issue in CompositeScope.close(), where the check-and-set operation on the volatile closed flag is not atomic, and suggests using a ReentrantLock to ensure thread-safe idempotency.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request enhances CompositeTracer to manage scopes more robustly, introducing fast paths for empty or single-child tracers, catching Error alongside RuntimeException during scope closure, and wrapping completion methods in try-with-resources blocks to ensure proper scoping. It also introduces a thread-safe CompositeScope to prevent duplicate closures. The reviewer suggests replacing the ReentrantLock in CompositeScope with a more lightweight and idiomatic AtomicBoolean to track the closed state, which reduces boilerplate and avoids lock acquisition overhead.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request enhances CompositeTracer to safely handle null scopes from unstubbed mocks, catch Errors alongside RuntimeExceptions for proper cleanup, and wrap tracer operations in inScope() blocks to ensure thread-bound execution. Comprehensive unit tests are also added to verify these behaviors. The reviewer suggests further optimizing the inScope() method by avoiding anonymous Scope wrapper allocations when childScopes is empty or has a single active scope, while maintaining exception safety.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request updates CompositeTracer to properly manage scope lifecycle and handle potential null scopes or Error throwables. Specifically, it introduces fast paths for empty or single-child tracers, ignores null child scopes, catches and propagates Error alongside RuntimeException to ensure proper cleanup, and wraps all operation and attempt completion methods in a try-with-resources block using inScope(). Additionally, comprehensive unit tests have been added to verify these new behaviors, including edge cases for null scopes, errors, and cross-thread scoping. There are no review comments, and we have no further feedback to provide.
|
|




Updates
CompositeTracerto wrap attempt and operation completion/failure callbacks intry (Scope ignored = inScope())(with a null guard for unstubbed test mocks) so sibling and nested tracers execute with the active trace scope on the callback thread.b/499388983